package com.basic.modules.ykf.service.impl;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.basic.common.utils.ParamsModel;
import com.basic.common.utils.ParamUtils;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.basic.common.utils.PageUtils;
import com.basic.common.utils.Query;

import com.basic.modules.ykf.dao.YkfUserAttendanceRecordDao;
import com.basic.modules.ykf.entity.YkfUserAttendanceRecordEntity;
import com.basic.modules.ykf.service.YkfUserAttendanceRecordService;


@Service("ykfUserAttendanceRecordService")
public class YkfUserAttendanceRecordServiceImpl extends ServiceImpl<YkfUserAttendanceRecordDao, YkfUserAttendanceRecordEntity> implements YkfUserAttendanceRecordService {

    @Override
    public PageUtils queryPage(ParamsModel<YkfUserAttendanceRecordEntity> params) {
        QueryWrapper<YkfUserAttendanceRecordEntity> queryWrapper = ParamUtils.createQueryWrapperByDefaultSort(params);
        if (ObjectUtil.isNotEmpty(params) && ObjectUtil.isNotEmpty(params.getCondition()) && StrUtil.isNotBlank(params.getCondition().getKeyword())) {
            queryWrapper.lambda().like(YkfUserAttendanceRecordEntity::getUserName, params.getCondition().getKeyword());
        }
        IPage<YkfUserAttendanceRecordEntity> page = this.page(
                new Query<YkfUserAttendanceRecordEntity>().getPage(BeanUtil.beanToMap(params.getPage())),
                queryWrapper
        );
        return new PageUtils(page);
    }

}
